#ifndef __COMMON_H__
#define __COMMON_H__

typedef unsigned char  uint8_t;
typedef unsigned short  uint16_t;
typedef unsigned long   uint32_t;
typedef char    int8_t;
typedef short   int16_t;
typedef long    int32_t;





/** Swaps the upper byte with the lower byte in a 16 bit variable */
//lint -emacro((572),SWAP) // Suppress warning 572 "Excessive shift value"
#define SWAP(x) ((((x)&0xFF)<<8)|(((x)>>8)&0xFF))

/** The upper 8 bits of a 16 bit value */
#define MSB(a) ((a & 0xFF00) >> 8)
/** The lower 8 bits (of a 16 bit value) */
#define LSB(a) ((a & 0xFF))

/** Leaves the minimum of the two arguments */
#define MIN(a, b) ((a) < (b) ? (a) : (b))
/** Leaves the maximum of the two arguments */
#define MAX(a, b) ((a) < (b) ? (b) : (a))

#define BIT_0 0x01 /**< The value of bit 0 */
#define BIT_1 0x02 /**< The value of bit 1 */
#define BIT_2 0x04 /**< The value of bit 2 */
#define BIT_3 0x08 /**< The value of bit 3 */
#define BIT_4 0x10 /**< The value of bit 4 */
#define BIT_5 0x20 /**< The value of bit 5 */
#define BIT_6 0x40 /**< The value of bit 6 */
#define BIT_7 0x80 /**< The value of bit 7 */



typedef union {
	uint32_t Val;
	uint16_t w[2] ;
	uint8_t  v[4] ;

	struct {
		uint16_t LW;
		uint16_t HW;
	} word;

	struct {
		uint8_t LB;
		uint8_t HB;
		uint8_t UB;
		uint8_t MB;
	} byte;

	struct {
		 uint8_t b0:1;
		 uint8_t b1:1;
		 uint8_t b2:1;
		 uint8_t b3:1;
		 uint8_t b4:1;
		 uint8_t b5:1;
		 uint8_t b6:1;
		 uint8_t b7:1;
		 uint8_t b8:1;
		 uint8_t b9:1;
		 uint8_t b10:1;
		 uint8_t b11:1;
		 uint8_t b12:1;
		 uint8_t b13:1;
		 uint8_t b14:1;
		 uint8_t b15:1;
		 uint8_t b16:1;
		 uint8_t b17:1;
		 uint8_t b18:1;
		 uint8_t b19:1;
		 uint8_t b20:1;
		 uint8_t b21:1;
		 uint8_t b22:1;
		 uint8_t b23:1;
		 uint8_t b24:1;
		 uint8_t b25:1;
		 uint8_t b26:1;
		 uint8_t b27:1;
		 uint8_t b28:1;
		 uint8_t b29:1;
		 uint8_t b30:1;
		 uint8_t b31:1;
	} bits;
} UINT32_VAL;





#endif


